package com.pdg.mcplugin.tsa;

import java.io.File;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.permissions.PermissionDefault;

public class Constants {
	public final static String signStartLine = "[TSA]"; 
	public final static String signArrivalLine = "ARRIVAL";
	public final static String signDepartureLine = "DEPARTURE";
	
	public final static String errorDeparturePointUse = ChatColor.RED + "[TSA] You do not have permission to use departure points.";
	public final static String errorDeparturePointUseCost = ChatColor.RED + "[TSA] Could not determine cost of travel. This departure point is invalid.";
	public final static String errorDeparturePointUseNoEconomy = ChatColor.RED + "[TSA] Economy not hooked in, so no travel for you.";
	public final static String errorDeparturePointUseContraband = ChatColor.RED + "[TSA] You are not allowed to carry contraband through the departure point.";
	public final static String errorDeparturePointUseNotEnoughMoney = ChatColor.RED + "[TSA] You cannot afford transit fee of %f.";
	public final static String errorDeparturePointUseArrivalPointNotFound = ChatColor.RED + "[TSA] could not find an arrival point named '%s'.";
	public final static String errorCouldNotCreateDataFolder = "[TSA] Failed to create data folder!";
	public final static String errorCouldNotLoadSQLite = "[TSA] Could not load SQLite!";
	public final static String errorCouldNotConnectToDatabase = "[TSA] Failed to open connection to database!";
	public final static String errorCouldNotCreateArrivalsTable = "[TSA] Failed to create arrivals table!";
	public final static String errorCouldNotCreateArrivalPoint = "[TSA] Failed to create Arrival Point!";
	public final static String errorCouldNotCreateArrivalSign = ChatColor.RED + "[TSA] arrival point could not be created.";
	public final static String errorCouldNotRetrieveArrivalPoint = "[TSA] Failed to retrieve Arrival point!";
	public final static String errorCouldNotDeleteArrivalPoint = "[TSA] Failed to delete Arrival point!";
	public final static String errorNoPermissionToPlaceArrivalPoint = ChatColor.RED + "[TSA] you do not have permission to place TSA arrival points.";
	public final static String errorInvalidArrivalPoint = ChatColor.RED + "[TSA] third line of sign must specify the name of arrival point.";
	public final static String errorCouldNotReplaceArrivalSign = ChatColor.RED + "[TSA] arrival point could not be replaced.";
	public final static String errorNoPermissionToReplaceArrivalPoint = ChatColor.RED + "[TSA] arrival point with that name already exists (and you don't have the permission to replace it).";
	public final static String errorNoPermissionToPlaceDeparturePoint = ChatColor.RED + "[TSA] you do not have permission to place TSA departure points.";
	public final static String errorNegativeTravelCost = ChatColor.RED + "[TSA] fourth line of sign must specify a non-negative cost of travel.";
	public final static String errorCostNotSpecified = ChatColor.RED + "[TSA] fourth line of sign must specify the cost of travel.";
	public final static String errorInvalidCost = ChatColor.RED + "[TSA] fourth line of sign must specify a valid cost of travel.";
	public final static String errorNoArrivalPointSpecified = ChatColor.RED + "[TSA] third line of sign must specify the name of arrival point.";
	public final static String errorInvalidSignType = ChatColor.RED + "[TSA] second line of sign must specify ARRIVAL or DEPARTURE.";
	public final static String errorNoPermissionToDestroyDepartureSign = ChatColor.RED + "[TSA] You do not have permission to destroy departure signs.";
	public final static String errorNoPermissionToDestroyArrivalSign = ChatColor.RED + "[TSA] You do not have permission to destroy arrival signs.";
	public final static String errorNoItemName = ChatColor.RED + "[TSA] You must provide an item name!";
	public final static String errorInvalidItemName = ChatColor.RED + "[TSA] Invalid item name '%s'.";
	public final static String errorCouldNotCreateContrabandTable = "[TSA] Could not create contraband table.";
	public final static String errorCouldNotCreateBlocksTable = "[TSA] Could not create blocks table.";
	public final static String errorCouldNotPermitContraband = "[TSA] Could not permit contraband.";
	public final static String errorCouldNotProhibitContraband = "[TSA] Could not prohibit contraband.";
	public final static String errorNoPermissionToListContraband = ChatColor.RED + "[TSA] You do not have permission to list contraband.";
	public final static String errorNoPermissionToPermitContraband = ChatColor.RED + "[TSA] You do not have permission to permit contraband.";
	public final static String errorNoPermissionToProhibitContraband = ChatColor.RED + "[TSA] You do not have permission to prohibit contraband.";
	public final static String errorNoPermissionToCheckContraband = ChatColor.RED + "[TSA] You do not have permission to check contraband.";
	public final static String errorMustPlaceOnDoubleStep = ChatColor.RED + "[TSA] Signs must be placed attached to a double step!";
	public final static String errorBlockProtectedByTSA = ChatColor.RED + "[TSA] This block is protected by TSA.";
	public final static String errorNoPermissionToClearContraband = ChatColor.RED + "[TSA] You do not have permission to clear the contraband list!";
	
	
	public final static String messageDeparturePointUseArrive = ChatColor.GREEN + "[TSA] you've arrived at '%s'.";
	public final static String messageDeparturePointUsePaid = ChatColor.GREEN + "[TSA] You pay the transit fee of %f.";
	public final static String messageCreatedDataFolder = "[TSA] Created data folder!";
	public final static String messageTSAEnabled = "[TSA] Enabled";
	public final static String messageTSADisabled = "[TSA] Disabled";
	public final static String messageArrivalPointCreated = ChatColor.GREEN + "[TSA] arrival point created.";
	public final static String messageArrivalPointReplaced = ChatColor.GREEN + "[TSA] arrival point replaced.";
	public final static String messageDeparturePointCreated = ChatColor.GREEN + "[TSA] departure point created.";
	public final static String messageIConomyUnhooked = "[TSA] iConomy is unhooked!";
	public final static String messageIConomyHooked = "[TSA] iConomy is hooked!";
	public final static String messageArrivalPointDestroyed = ChatColor.GREEN + "[TSA] arrival point destroyed.";
	public final static String messageDeparturePointDestroyed = ChatColor.GREEN + "[TSA] departure point destroyed.";
	public final static String messageNoContrabandList = ChatColor.GREEN+"[TSA] Nothing on contraband list.";
	public final static String messagePermittedContraband = ChatColor.GREEN +"[TSA] Item now permitted.";
	public final static String messageProhibitedContraband = ChatColor.GREEN +"[TSA] Item now prohibited.";
	public final static String messageItemIsProhibited = ChatColor.GREEN + "[TSA] The item is prohibited.";
	public final static String messageItemIsPermitted = ChatColor.GREEN + "[TSA] The item is permitted.";
	public final static String messageContrabandListCleared = ChatColor.GREEN + "[TSA] The contraband list has been cleared.";
	
	
	public final static String classNameSQLite = "org.sqlite.JDBC";
	public final static String classNameIConomy = "com.iCo6.iConomy";
	
	public final static String connectionString = "jdbc:sqlite:%s"+ File.separator + "tsa.db";
	
	public final static String pluginIConomy = "iConomy";
	
	public final static String tableArrivals = "tsa_arrivals";
	public final static String fieldArrivalName = "arrival_name";
	public final static String fieldArrivalWorld = "arrival_world";
	public final static String fieldArrivalX = "arrival_location_x";
	public final static String fieldArrivalY = "arrival_location_y";
	public final static String fieldArrivalZ = "arrival_location_z";
	
	public final static String tableContraband = "tsa_contraband";
	public final static String fieldMaterialId = "material_id";
	
	public final static String tableBlocks = "tsa_blocks";
	public final static String fieldBlockWorld = "block_world";
	public final static String fieldBlockX = "block_x";
	public final static String fieldBlockY = "block_y";
	public final static String fieldBlockZ = "block_z";
	public final static String fieldBlockProtection = "block_protection";

	public final static String dbCheckForArrivalsTable = "SELECT `name` FROM `sqlite_master` WHERE `type`='table' AND `name`='"+tableArrivals+"';";
	public final static String dbCreateArrivalsTable = "CREATE TABLE IF NOT EXISTS `"+tableArrivals+"` (`"+fieldArrivalName+"` TEXT UNIQUE, `"+fieldArrivalWorld+"` TEXT, `"+fieldArrivalX+"` REAL, `"+fieldArrivalY+"` REAL, `"+fieldArrivalZ+"` REAL);";
	public final static String dbInsertArrivalPoint = "INSERT INTO `"+tableArrivals+"` (`"+fieldArrivalName+"`,`"+fieldArrivalWorld+"`,`"+fieldArrivalX+"`,`"+fieldArrivalY+"`,`"+fieldArrivalZ+"`) VALUES ('%s','%s',%f,%f,%f);";
	public final static String dbRetrieveArrivalPoint = "SELECT `"+fieldArrivalWorld+"`,`"+fieldArrivalX+"`,`"+fieldArrivalY+"`,`"+fieldArrivalZ+"` FROM `"+tableArrivals+"` WHERE `"+fieldArrivalName+"`='%s';";
	public final static String dbDeleteArrivalPoint = "DELETE FROM `"+tableArrivals+"` WHERE `"+fieldArrivalName+"`='%s';";
	
	public final static String dbCheckForContrabandTable = "SELECT `name` FROM `sqlite_master` WHERE `type`='table' AND `name`='"+tableContraband+"';";
	public final static String dbCreateContrabandTable = "CREATE TABLE IF NOT EXISTS '"+tableContraband+"' ('"+fieldMaterialId+"' INTEGER UNIQUE);";
	public final static String dbCheckContraband = "SELECT `"+fieldMaterialId+"` FROM `"+tableContraband+"` WHERE `"+fieldMaterialId+"`=%d;";
	public final static String dbListContraband = "SELECT `"+fieldMaterialId+"` FROM `"+tableContraband+"` ORDER BY `"+fieldMaterialId+"`;";
	public final static String dbProhibitContraband = "INSERT INTO `"+tableContraband+"` (`"+fieldMaterialId+"`) VALUES (%d);";
	public final static String dbPermitContraband = "DELETE FROM `"+tableContraband+"` WHERE `"+fieldMaterialId+"`=%d;";
	public final static String dbClearContraband = "DELETE FROM `"+tableContraband+"`;";
	
	public final static String dbCheckForBlocksTable = "SELECT `name` FROM `sqlite_master` WHERE `type`='table' AND `name`='"+tableBlocks+"';";
	public final static String dbCreateBlocksTable = "CREATE TABLE IF NOT EXISTS `"+tableBlocks+"` (`"+fieldBlockWorld+"` TEXT,`"+fieldBlockX+"` REAL,`"+fieldBlockY+"` REAL,`"+fieldBlockZ+"` REAL,`"+fieldBlockProtection+"` INTEGER);";
	public final static String dbCreateBlock = "INSERT INTO `"+tableBlocks+"` (`"+fieldBlockWorld+"`,`"+fieldBlockX+"`,`"+fieldBlockY+"`,`"+fieldBlockZ+"`,`"+fieldBlockProtection+"`) VALUES ('%s',%f,%f,%f,%d)";
	public final static String dbRetrieveBlock = "SELECT `"+fieldBlockProtection+"` FROM `"+tableBlocks+"` WHERE `"+fieldBlockWorld+"`='%s' AND `"+fieldBlockX+"`=%f AND `"+fieldBlockY+"`=%f AND `"+fieldBlockZ+"`=%f;";
	public final static String dbUpdateBlock = "UPDATE `"+tableBlocks+"` SET `"+fieldBlockProtection+"`=%d  WHERE `"+fieldBlockWorld+"`='%s' AND `"+fieldBlockX+"`=%f AND `"+fieldBlockY+"`=%f AND `"+fieldBlockZ+"`=%f;";
	public final static String dbDeleteBlock = "DELETE FROM `"+tableBlocks+"` WHERE `"+fieldBlockWorld+"`='%s' AND `"+fieldBlockX+"`=%f AND `"+fieldBlockY+"`=%f AND `"+fieldBlockZ+"`=%f;";
	
	public final static Integer signLineTsa = 0;
	public final static Integer signLineType = 1;
	public final static Integer signLineArrivalPoint = 2;
	public final static Integer signLineCost = 3;
	
	public final static String permissionDepartureSignPassenger = "tsa.departuresign.passenger";
	public final static PermissionDefault permissionDefaultDeparturesSignPassenger = PermissionDefault.TRUE;
	
	public final static String permissionDepartureSignMarshal = "tsa.departuresign.marshal";
	public final static PermissionDefault permissionDefaultDepartureSignMarshal = PermissionDefault.FALSE;
	
	public final static String permissionDepartureSignCreate = "tsa.departuresign.create";
	public final static PermissionDefault permissionDefaultDepartureSignCreate = PermissionDefault.OP;
	
	public final static String permissionDepatureSignDestroy = "tsa.departuresign.destroy";
	public final static PermissionDefault permissionDefaultDepatureSignDestroy = PermissionDefault.OP;
	
	public final static String permissionArrivalSignCreate = "tsa.arrivalsign.create";
	public final static PermissionDefault permissionDefaultArrivalSignCreate = PermissionDefault.OP;
	
	public final static String permissionArrivalSignDestroy = "tsa.arrivalsign.destroy";
	public final static PermissionDefault permissionDefaultArrivalSignDestroy = PermissionDefault.OP;
	
	public final static String permissionArrivalSignUpdate = "tsa.arrivalsign.update";
	public final static PermissionDefault permissionDefaultArrivalSignUpdate = PermissionDefault.OP;
	
	public final static String permissionContrabandList = "tsa.contraband.list";
	public final static PermissionDefault permissionDefaultContrabandList = PermissionDefault.TRUE;
	
	public final static String permissionContrabandPermit = "tsa.contraband.permit";
	public final static PermissionDefault permissionDefaultContrabandPermit = PermissionDefault.OP;
	
	public final static String permissionContrabandProhibit = "tsa.contraband.prohibit";
	public final static PermissionDefault permissionDefaultContrabandProhibit = PermissionDefault.OP;
	
	public final static String permissionContrabandCheck = "tsa.contraband.check";
	public final static PermissionDefault permissionDefaultContrabandCheck = PermissionDefault.TRUE;
	
	public final static String permissionContrabandClear = "tsa.contraband.clear";
	public final static PermissionDefault permissionDefaultContrabandClear = PermissionDefault.OP;
	
	public final static Double costZero = 0.0;
	
	public final static Integer protectionZero = 0;
	public final static Integer protectionMaximum = 5;
	
	public final static String loggerName = "Minecraft";
	
	public final static Integer argSubcommand = 0;
	public final static Integer argContrabandTask = 1;
	public final static Integer argItemNameStart = 2;
	public final static Integer argCountZero = 0;
	public final static Integer argCountSingle = 1;
	public final static Integer argCountDouble = 2;
	
	public final static String commandTSA = "TSA";
	public final static String subcommandHelp = "HELP";
	public final static String subcommandQuestion = "?";
	public final static String subcommandArrivalSign = "ARRIVALSIGN";
	public final static String subcommandDepartureSign = "DEPARTURESIGN";
	public final static String subcommandContraband = "CONTRABAND";
	public final static String contrabandTaskList = "LIST";
	public final static String contrabandTaskProhibit = "PROHIBIT";
	public final static String contrabandTaskPermit = "PERMIT";
	public final static String contrabandTaskCheck = "CHECK";
	public final static String contrabandTaskClear = "CLEAR";
	
	public final static String[] helpGeneral = {
		"/tsa (?|help)      - general help",
		"/tsa arrivalsign   - arrival sign help",
		"/tsa departuresign - departure sign help",
		"/tsa contraband    - contraband help"
	};
	public final static String[] helpArrivalSign = {
		"[TSA] To make an Arrival Sign:",
		"Line 1: [tsa]",
		"Line 2: arrival",
		"Line 3: Name of arrival point"
	};
	public final static String[] helpDepartureSign = {
		"[TSA] To make an Departure Sign:",
		"Line 1: [tsa]",
		"Line 2: departure",
		"Line 3: Name of arrival point",
		"Line 4: cost"
	};
	public final static String[] helpContraband = {
		"[TSA] Contraband subcommand help:",
		"/tsa contraband list",
		"/tsa contraband prohibit [item name]",
		"/tsa contraband permit [item name]",
		"/tsa contraband check [item name]",
		"/tsa contraband clear"
	};
	
	public final static Material[] defaultContraband = {
		Material.ARROW,
		Material.BOW,
		Material.CACTUS,
		Material.DIAMOND_AXE,
		Material.DIAMOND_SWORD,
		Material.FLINT_AND_STEEL,
		Material.GOLD_AXE,
		Material.GOLD_SWORD,
		Material.IRON_AXE,
		Material.IRON_SWORD,
		Material.LAVA_BUCKET,
		Material.MILK_BUCKET,
		Material.SHEARS,
		Material.STONE_AXE,
		Material.STONE_SWORD,
		Material.SULPHUR,
		Material.TNT,
		Material.WATER_BUCKET,
		Material.WOOD_AXE,
		Material.WOOD_SWORD
	};
	
}
